package com.md.utils;
import android.content.Context;
import android.text.TextUtils;
import com.md.nohttp.CallServer;
import com.md.nohttp.CustomHttpListener;
import com.md.nohttp.CustomHttpListenermoney;
import com.yolanda.nohttp.rest.Request;


public class commonGet {
    private static Request<String> mRequest;


//    /**
//     * @param name        接口名称
//     * @param phone       手机号或者邮箱
//     * @param baseContext
//     * @param callback    回调
//     */
//    public static void getsmscode(String name, String phone, final Context baseContext, final StringCallback callback) {
//        mRequest = NoHttp.createStringRequest(name, HttpIp.POST);
//        mRequest.add("userName", phone);
//        getRequest(baseContext, new CustomHttpListener<Comment>(baseContext, true, Comment.class) {
//            @Override
//            public void doWork(Comment data, String code) {
//                if ("100".equals(data.getMsgcode())) {
//                    callback.doWork(data.getObject());
//                }
//            }
//
//            @Override
//            public void onFinally(JSONObject obj, String code, boolean isNetSucceed) {
//                super.onFinally(obj, code, isNetSucceed);
//                if (obj != null) {
//                    try {
//                        CommonUtil.showToask(baseContext, obj.getString("msg"));
//                    } catch (Exception e) {
//                        e.printStackTrace();
//                    }
//                }
//            }
//        }, true);
//    }









    public interface StringCallback {
        void doWork(String string);
    }

    public interface StringtwoCallback {
        void doWork(String s1, String s2);
    }

    public interface StringtCallback {
        void doWork(String startDate, String endDate, String totleNum);
    }

    public interface CountryCallback {
        void doWork(String[] s1);
    }

    public interface UpdateCallback {
        void doWork(String content, String ywcontent, String uel);
    }

    //Nohttp请求
    public static <T> void getRequest(Context baseContext, CustomHttpListener<T> customHttpListener, boolean isloading) {
        if (!TextUtils.isEmpty(PreferencesUtils.getString(baseContext, "token"))) {
            mRequest.addHeader("token", PreferencesUtils.getString(baseContext, "token"));
        }
        mRequest.add("environment", PreferencesUtils.getInt(baseContext, "languare"));
        CallServer.getRequestInstance().add(baseContext, mRequest, customHttpListener, isloading);
    }

    public static <T> void getRequest(Context baseContext, CustomHttpListenermoney<T> customHttpListener, boolean isloading) {
        if (!TextUtils.isEmpty(PreferencesUtils.getString(baseContext, "token"))) {
            mRequest.addHeader("token", PreferencesUtils.getString(baseContext, "token"));
        }
        mRequest.add("environment", PreferencesUtils.getInt(baseContext, "languare"));
        CallServer.getRequestInstance().add(baseContext, mRequest, customHttpListener, isloading);
    }

}
